package com.example.mychatgpt.controller;

import com.example.mychatgpt.service.userService;
import com.example.mychatgpt.utils.R;
import org.apache.ibatis.jdbc.Null;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@CrossOrigin
public class userController {
    @Autowired
    userService my;
    @PostMapping("/user/login")
    R login(@RequestBody Map<String,Object> data){
        String account=data.get("account").toString(),password=data.get("password").toString();
        int id=my.checkValid(account,password);
        switch (id){
            case -2:return new R(false,"未找到账户",null);
            case -1:return new R(false,"密码不正确",null);
            default:return new R(true,"登录成功",null);
        }
    }
}
